/**
 * Created by user on 2018/4/24.
 */
import React, {Component} from 'react'
import {Route, Redirect} from 'react-router-dom'
import {connect} from 'react-redux'

class AuthRoute extends Route {
  render() {
    const { isAuth } = this.props
    return isAuth ?
      super.render() :
      <Redirect
        to={{
          pathname: "/login",
          state: {from: this.props.location}
        }}
      />
  }
}


const mapState = state => ({
  isAuth: state.GlobalState.isAuth
})

export default connect(mapState)(AuthRoute)






